home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / cpp_libs / awe2-0_1.lha / awe2-0.1 / Src / RCS / HardwareContext-sparc.h,v < prev    next >
Text File  |  1990-06-28  |  4KB  |  202 lines

  1. head     1.3;
  2. branch   ;
  3. access   ;
  4. symbols  ;
  5. locks    grunwald:1.3; strict;
  6. comment  @ * @;
  7.  
  8.  
  9. 1.3
  10. date     90.06.28.14.46.50;  author grunwald;  state Exp;
  11. branches ;
  12. next     1.2;
  13.  
  14. 1.2
  15. date     90.06.08.17.42.43;  author grunwald;  state Exp;
  16. branches ;
  17. next     1.1;
  18.  
  19. 1.1
  20. date     90.06.08.17.27.21;  author grunwald;  state Exp;
  21. branches ;
  22. next     ;
  23.  
  24.  
  25. desc
  26. @@
  27.  
  28.  
  29. 1.3
  30. log
  31. @*** empty log message ***
  32. @
  33. text
  34. @// This may look like C code, but it is really -*- C++ -*-
  35. // 
  36. // Copyright (C) 1988 University of Illinois, Urbana, Illinois
  37. //
  38. // written by Dirk Grunwald (grunwald@@cs.uiuc.edu)
  39. //
  40. #ifndef    HardwareContext_h
  41. #define    HardwareContext_h
  42. #pragma once
  43.  
  44. #include <stream.h>
  45. #include <assert.h>
  46. #include <AwesimeConfig.h>
  47. #include <setjmp.h>
  48.  
  49. extern long MagicStackMarker;
  50.  
  51. typedef void (*voidFuncP)();
  52.  
  53. class CpuMultiplexor;
  54. class SingleCpuMux;
  55. class MultiCpuMux;
  56. class SimulationMultiplexor;
  57. class SingleSimMux;
  58.  
  59. typedef unsigned long HardwareContextQuad;
  60.  
  61. #define HARDWARE_CONTEXT_CHECK_NONE 0
  62. #define HARDWARE_CONTEXT_CHECK_SWITCH 1
  63. #define HARDWARE_CONTEXT_CHECK_MPROTECT 2
  64.  
  65. class HardwareContext {
  66.     //
  67.     //    The following two fields are machine dependent & their order
  68.     //    should not be changed.
  69.     //
  70.     HardwareContextQuad sp;
  71.  
  72.     HardwareContextQuad INs[8];
  73.     HardwareContextQuad LOCALs[8];
  74.  
  75.     HardwareContextQuad pc;
  76.     HardwareContextQuad out0;
  77.  
  78.     void** stackBase;    // bottom of stack
  79.     void** stackEnd;    // maximum depth of stack? (actually, a MIN value)
  80.     unsigned stackMax;    // maximum depth of stack? (actually, a MIN value)
  81.     unsigned stackSize;    // stack size in units of void*
  82.     void** stackMallocAt;
  83.  
  84.     //
  85.     // point to MagicStackMarker to check for corruption
  86.     //
  87.     long *stackCheck;
  88.     unsigned checkStackLimits;
  89.  
  90.     friend class Thread;
  91.  
  92.     friend class CpuMultiplexor;
  93.     friend class SingleCpuMux;
  94.     friend class MultiCpuMux;
  95.  
  96.     friend class SimulationMultiplexor;
  97.     friend class SingleSimMux;
  98.     
  99.     //
  100.     //    Accessed by friend classes only
  101.     //
  102.     void switchContext(HardwareContext *to);
  103.     void magicSwitchTo(HardwareContext *to);
  104.     void **getSp();
  105.     
  106.     void **mallocAt();
  107.     void buildReturnFrame(void * returnThis, voidFuncP returnAddress);
  108.     void stackOverflow();
  109.     
  110.     //
  111.     // never allocated by anything other than friend classes
  112.     //
  113.     HardwareContext(int checked, unsigned stackSize);
  114.     
  115.     void reclaimStack();
  116.  
  117. public:
  118.     HardwareContext();
  119.     
  120.     long maxStackDepth();
  121.     void checkStack(int overage = 0);
  122.     void classPrintOn(ostream& strm);
  123. };
  124.  
  125. static inline
  126. HardwareContext::HardwareContext()
  127. {
  128.     int NotReached = 0;
  129.     assert( NotReached );
  130. }
  131.  
  132. static inline ostream&
  133. operator<<(ostream& strm, HardwareContext& ob)
  134. {
  135.     ob.classPrintOn(strm);
  136.     return strm;
  137. }
  138.  
  139. static inline long
  140. HardwareContext::maxStackDepth()
  141. {
  142.     return( long(stackMax) );
  143. }
  144.  
  145. static inline void **
  146. HardwareContext::getSp()
  147. {
  148.     register int theStackPointer asm("%sp");
  149.     return( (void **) theStackPointer );
  150. }
  151.  
  152.  
  153. static inline void
  154. HardwareContext::checkStack(int overage)
  155. {
  156.     unsigned depth = stackBase - getSp() + overage;
  157.     if (stackMax < depth) {
  158.     stackMax = depth;
  159.     }
  160.     if ( stackMax >= stackSize || *stackCheck != MagicStackMarker ) {
  161.     stackOverflow();
  162.     }
  163. }
  164.  
  165. #endif    HardwareContext_h
  166. @
  167.  
  168.  
  169. 1.2
  170. log
  171. @*** empty log message ***
  172. @
  173. text
  174. @d28 4
  175. a74 1
  176.     void buildHiddenReturnFrame(void * returnThis, voidFuncP returnAddress);
  177. d82 2
  178. d118 1
  179. @
  180.  
  181.  
  182. 1.1
  183. log
  184. @Initial revision
  185. @
  186. text
  187. @d16 1
  188. a16 1
  189. extern const long MagicStackMarker;
  190. a33 1
  191.     HardwareContextQuad fp;
  192. d35 3
  193. a37 1
  194. #if 0
  195. d39 1
  196. a39 4
  197. #else
  198.     HawareContextQuad IN[8];
  199.     HawareContextQuad LOCAL[8];
  200. #endif
  201. @
  202.